***2020 American National Election Time-Series Study***
clear
use "/Users/ryandawkins/Dropbox/Datasets/2020 ANES Time-Series.dta"


sort V160001_orig
 
 merge V160001_orig using "/Users/ryandawkins/Dropbox/Working Papers/Partisan Foundations to American National Identity/Publication Files/Replication file - 2016-2020 Merge.dta"

 
set scheme plotplain, perm

*Partisanship/Ideology/Interest*
recode V201231x (-9/-8=.)(1=0 "Strong Democrat")(2=1 "Weak Democrat")(3=2 "Lean Democrat")(4=3 "Independent")(5=4 "Lean Republican")(6=5 "Weak Republican")(7=6 "Strong Republican"), gen(republican)

recode republican (0/2=0 "Democrat")(3=1 "Independent")(4/6=2 "Republican"), gen(gop3)


recode V201200 (-9 -8=.)(1=0 "very liberal")(2=1 "liberal")(3=2 "lean liberal")(4 99=3 "moderate")(5=4 "lean conservative")(6=5 "conservative")(7=6 "very conservative"), gen(conservative)


recode V202406 (-9/-5=.)(4=0 "not interested at all")(3=1 "not very interested")(2=2 "somewhat interested")(1=3 "very interested"), gen(polinterest)

recode republican (3=0 "ind")(4 2=1 "lean")(1 5=2 "weak")(0 6=3 "strong"), gen(spid)

recode V202433 (-9/-5=.), gen(demlike)
recode V202434 (-9/-5=.), gen(goplike)

gen outparty_like=.
replace outparty_like=demlike if gop3==2
replace outparty_like=goplike if gop3==0

recode V201152 (-9=.), gen(trumpfeels20)

*Demographics*
recode V201511x (-9/-2=.) (1=0 "no diploma")(2=1 "HS Diploma")(3=2 "some college")(4=3 "B.A. degree")(5=4 "graduate degree"), gen (educ)

gen female=.
replace female=0 if V201600==1
replace female=1 if V201600==2

recode V201507x (-9=.), gen (age)


recode V201156 (-9/-5=.)(998 999=.), gen(demfeels)
recode V201157 (-9/-5=.)(998 999=.), gen (gopfeels)

gen outpartyfeels=.
replace outpartyfeels=gopfeels if republican<3
replace outpartyfeels=demfeels if republican>3


recode V202421 (-9/-5=.)(4=0)(3=1)(2=2)(1=3), gen(bornus)
recode V202422 (-9/-5=.)(4=0)(3=1)(2=2)(1=3), gen(ancestry)
recode V202423 (-9/-5=.)(4=0)(3=1)(2=2)(1=3), gen(english)
recode V202424 (-9/-5=.)(4=0)(3=1)(2=2)(1=3), gen(customs)

recode V202419 (-9/-5=.)(5=0)(4=1)(3=2)(2=3)(1=4), gen(culture_threat)
recode V202416 (-9/-5=.)(5=0)(4=1)(3=2)(2=3)(1=4), gen(assimilate)

gen nativism20=(bornus+ancestry+english+customs)

recode V202300 (-9/-5=.) (5=0 "disagree strongly")(4=1 "disagree somewhat")(3=2 "neither agree nor disagree")(2=3 "agree somewhat")(1=4 "agress strongly"), gen(specialfavors)

recode V202303 (-9/-5=.) (5=0 "disagree strongly")(4=1 "disagree somewhat")(3=2 "neither agree nor disagree")(2=3 "agree somewhat")(1=4 "agress strongly"), gen(triedharder)

recode V202302 (-9/-5=.) (1=0 "disagree strongly")(2=1 "disagree somewhat")(3=2 "neither agree nor disagree")(4=3 "agree somewhat")(5=4 "agress strongly"), gen(lessdeserve)

recode V202301 (-9/-5=.) (1=0 "disagree strongly")(2=1 "disagree somewhat")(3=2 "neither agree nor disagree")(4=3 "agree somewhat")(5=4 "agress strongly"), gen(pastdiscrim)

gen resentment=(specialfavors+triedharder+lessdeserve+pastdiscrim)


rename V200010b weight

gen gop2=.
replace gop2=0 if gop3==0
replace gop2=1 if gop3==2

 gen polarization=abs(outparty_like-10)
 
 gen nativism_chng=nativism20-nativism16
 gen trumpfeels_chng=trumpfeels20-trumpfeels16
 
 recode V201549x (-9 -8=.)(1=1 "White")(2=2 "Black")(3=3 "Hispanic")(4=4 "Asian")(5=5 "Indigenous"), gen(race)
 
 
********** Analysis *****************
*									*
*									*
*************************************
sum nativism20 if race==1, d 

sum polarization if race==1, d 

alpha bornus ancestry english customs if race==1, item
alpha bornus ancestry english customs if race==1 & gop2==0, item
alpha bornus ancestry english customs if race==1 &gop2==1, item

factor bornus ancestry english customs if race==1, pcf
rotate, promax blanks (.4)
estat common

** Sorting Analysis **
reg nativism20 gop2 if race==1 [pw=V200015b]  

corr nativism20 republican if race==1 [aweight= V200015b]

  twoway (kdensity nativism if gop3==0 & race==1) (kdensity nativism if gop3==2 & race==1)
  
** Change Analysis **
  
reg nativism_chng nativism16 gop2_16 resentment16 age female education  if race==1 [pweight= V200011b] 
reg nativism_chng nativism16 gop2_16 trumpfeels16 resentment16 age female education if race==1 [pweight= V200011b]
margins, at(trumpfeels16=(0(10)100)) atmeans
marginsplot

reg trumpfeels_chng nativism16 gop2_16 trumpfeels16 resentment16 age female education if race==1 [pweight= V200011b] 


** Polarization Analysis **
reg polarization educ female age polinterest conservative spid c.nativism20##c.gop2 if race==1 [pw=V200015b]

margins, at(nativism=(0(2)12) gop2=(0 1)) atmeans 

